package com.openjava.example.order.service.fallback;

import com.openjava.example.order.domain.ExampleOrder;
import com.openjava.example.order.service.ExampleOrderClient;
import feign.hystrix.FallbackFactory;
import org.ljdp.component.result.BasicApiResponse;
import org.springframework.stereotype.Component;

//@Component
public class HystrixClientFallbackFactory implements FallbackFactory<ExampleOrderClient> {
    @Override
    public ExampleOrderClient create(Throwable cause) {
        return new ExampleOrderClient() {
            @Override
            public ExampleOrder get(Long id){
                ExampleOrder order = new ExampleOrder();
                order.setCode(3000);
                order.setMessage("服务器繁忙");
                return order;
            }

            @Override
            public BasicApiResponse hi(){
                BasicApiResponse response = new BasicApiResponse();
                response.setCode(3000);
                response.setMessage("服务器访问不了");
                return response;
            }
        };
    }
}